<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>种养殖一体化智慧管理平台</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <link rel="icon" href="/statics/favicon.ico" />
    <link rel="stylesheet" href="${request.contextPath}/statics/css/bootstrap.min.css">
    <link rel="stylesheet" href="${request.contextPath}/statics/css/font-awesome.min.css">
    <link rel="stylesheet" href="${request.contextPath}/statics/css/AdminLTE.min.css">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" href="${request.contextPath}/statics/css/all-skins.min.css">
    <link rel="stylesheet" href="${request.contextPath}/statics/css/main.css">
    <link rel="stylesheet" href="statics/plugins/layer/skin/default/layer.css">
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body class="hold-transition login-page" style="background-image: url('/statics/images/bg.png');background-repeat: no-repeat, repeat;background-size: 100%;background-color:#fff;">
<div class="login-box" id="witapp" v-cloak>
    <div class="login-box-body">
        <p class="login-box-msg"><b>登录入口</b></p>
        <div v-if="error" class="alert alert-danger alert-dismissible" style="border-radius:4px;">
            <h4 style="margin-bottom: 0px;"><i class="fa fa-exclamation-triangle"></i>{{errorMsg}}</h4>
        </div>
        <div class="form-group has-feedback">
            <input type="text" class="form-control" v-model="username" placeholder="登录账号">
            <span class="glyphicon glyphicon-user form-control-feedback"></span>
        </div>
        <div class="form-group has-feedback">
            <input type="password" class="form-control" v-model="password" placeholder="账号密码">
            <span class="glyphicon glyphicon-lock form-control-feedback" title="手动输入"></span>
        </div>
        <div class="form-group has-feedback">
            <input type="text" class="form-control" v-model="captcha" @keyup.enter="login" placeholder="验证码">
            <span class="glyphicon glyphicon-warning-sign form-control-feedback"></span>
        </div>
        <div class="form-group has-feedback">
            <img alt="如果看不清楚，请单击图片刷新！" title="如果看不清楚,请单击图片刷新" class="pointer" :src="src" @click="refreshCode">
            &nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:;" @click="refreshCode">点击刷新</a>
        </div>
        <div class="row">
            <div class="col-xs-12">
                <button type="button" class="btn btn-success btn-block btn-flat" style="border-radius:4px;border: 1px solid transparent;padding:8px 0;background-image: linear-gradient(to right, #41C7AF , #6DE195);" @click="login">登录认证</button>
            </div>
        </div>
        <img style="height:224px;width:417px;position:absolute;margin-left:380px;top:20%;" src="/statics/images/subjoin.png"/>
    </div>
</div>
<div class="loginbm">
    CopyRight © 2014 贵州中航科技有限公司丨备案号：<a href="https://beian.miit.gov.cn/" target="_blank" style="color:#fff">黔ICP备20001485号-1</a>
</div>
<!-- /.login-box -->
<script src="${request.contextPath}/statics/libs/jquery.min.js"></script>
<script src="${request.contextPath}/statics/libs/vue.min.js"></script>
<script src="${request.contextPath}/statics/libs/bootstrap.min.js"></script>
<script src="${request.contextPath}/statics/libs/jquery.slimscroll.min.js"></script>
<script src="${request.contextPath}/statics/libs/fastclick.min.js"></script>
<script src="${request.contextPath}/statics/libs/app.js"></script>
<script src="statics/plugins/layer/layer.js"></script>
<script type="text/javascript">
    var vm = new Vue({
        el: '#witapp',
        data: {
            username: '',
            password: '',
            captcha: '',
            error: false,
            errorMsg: '',
            src: 'captcha.jpg'
        },
        beforeCreate: function(){
            if(self != top){
                top.location.href = self.location.href;
            }
        },
        methods: {
            refreshCode: function(){
                this.src = "captcha.jpg?t=" + $.now();
            },
            login: function(event){
                if(vm.username.length <= 0){
                    loginDialog('请输入登录账号');
                    return;
                }
                if(vm.password.length <= 0){
                    loginDialog('请输入账号密码');
                    return;
                }
                if(vm.captcha.length <= 0){
                    loginDialog('请输入图形验证码');
                    return;
                }
                var data = "username=" + vm.username + "&password=" + vm.password + "&captcha=" + vm.captcha;
                var layerIndex = top.layer.msg('登录中,请稍候……', {icon: 16, time: -1, shade: [0.3, '#000'], area: 'auto'});
                $.ajax({
                    type: "POST", url: "sys/login", data: data, dataType: "json", success: function(result){
                        layer.close(layerIndex);
                        if(result.code == 0){//登录成功
                            parent.location.href = 'index.html';
                        }else{
                            vm.error = true;
                            vm.errorMsg = result.msg;
                            vm.refreshCode();
                        }
                    }
                });
            }
        }
    });
    function loginDialog(msg){
        top.layer.alert(msg, {
            title: '系统提示', btnAlign: 'c', yes: function(index){
                top.layer.close(index);
            }, cancel: function(index, layero){
                top.layer.close(index);
            }
        });
    }
</script>
</body>
</html>